package com.red.mybatisSecond2;

import org.apache.ibatis.session.SqlSession;

import com.red.dao.StudentOperationDao;
import com.red.po.Student;
import com.red.util.SqlSessionFactoryUtil;




public class Chapter4_7_1Main {

	public static void main(String[] args) {
		SqlSession sqlSession = null;
		try {
			sqlSession=SqlSessionFactoryUtil.openSqlSession();
			StudentOperationDao studentOperationDao=sqlSession.getMapper(StudentOperationDao.class);
			Student student=studentOperationDao.getById(1);
			System.out.println(student);
			System.out.println(student.getName()+"的指导老师是:"+student.getSupervisor().getName());
			sqlSession.commit();
		} catch (Exception e) {
			e.printStackTrace();
			sqlSession.rollback();
		}finally {
			if(sqlSession!=null) {
				sqlSession.close();
			}
		}
		
	}

}
